package com.amat0urheu.controller.studentController;

import com.amat0urheu.pojo.ReturnRes;
import com.amat0urheu.service.TeamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
public class TeamController {

    final TeamService teamService;
    @Autowired
    public TeamController(TeamService teamService) {
        this.teamService = teamService;
    }

    @GetMapping("/user/viewTeam/{pageSize:\\d+}/{pageNum:\\d+}")
    public ReturnRes getTeamRankView(@PathVariable int pageSize,
                                 @PathVariable int pageNum) {
        return   teamService.getTeamView(pageSize,pageNum);
    }
    @GetMapping("/addTeamPeo/{tname}")
    public   ReturnRes addTeam(@PathVariable String tname,
                               Authentication authentication) {
       return  teamService.addTeam(tname,authentication.getName());

    }
    @GetMapping("/admin/team/search/{pageSize}/{pageNum}")
    public ReturnRes searchRaceByPageforAdmin(@PathVariable int pageSize,
                                      @PathVariable int pageNum,
                                      @RequestParam String key,
                                      @RequestParam String value) {
        return teamService.searchRaceByPageforAdmin(key, value, pageNum, pageSize);
    }




}
